Fix #332604, reported by Joe Wreschnig, patch by Jan Arne Petersen and
authorMatthias Clasen <mclasen@redhat.com>
Thu, 4 Jan 2007 05:58:32 +0000 (05:58 +0000)
committerMatthias Clasen <matthiasc@src.gnome.org>
Thu, 4 Jan 2007 05:58:32 +0000 (05:58 +0000)
2007-01-03  Matthias Clasen  <mclasen@redhat.com>

        Fix #332604, reported by Joe Wreschnig, patch
        by Jan Arne Petersen and Behdad Esfahbod.

        * gtk/gtklabel.c (gtk_label_size_allocate): Only
        set the width of the layout when necessary.
        (get_layout_location): Use pango_layout_get_pixel_extents()
        instead of pango_layout_get_width().

svn path=/trunk/; revision=17052

ChangeLog
gtk/gtklabel.c

index 0f72a02c339f5e528a544c6026c3bdb8a87b143c..04fc4e96687e4d5f014c39a8eb60686583ab337d 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,13 @@
+2007-01-03  Matthias Clasen  <mclasen@redhat.com>
+
+       Fix #332604, reported by Joe Wreschnig, patch
+       by Jan Arne Petersen and Behdad Esfahbod.
+
+       * gtk/gtklabel.c (gtk_label_size_allocate): Only
+       set the width of the layout when necessary.
+       (get_layout_location): Use pango_layout_get_pixel_extents()
+       instead of pango_layout_get_width().
+
 2007-01-03  Matthias Clasen  <mclasen@redhat.com>
 
        * modules/printbackends/cups/gtkprintbackendcups.c 
index 6b33909947f6495bcec437ac071fcb983fcd502c..d58754e7f7663ce66fb99fa8f318446c54631e7c 100644 (file)
@@ -2192,7 +2192,18 @@ gtk_label_size_allocate (GtkWidget     *widget,
   if (label->ellipsize)
     {
       if (label->layout)
-       pango_layout_set_width (label->layout, allocation->width * PANGO_SCALE);
+       {
+         gint width;
+         PangoRectangle logical;
+
+         width = (allocation->width - label->misc.xpad * 2) * PANGO_SCALE;
+
+         pango_layout_set_width (label->layout, -1);
+         pango_layout_get_extents (label->layout, NULL, &logical);
+
+         if (logical.width > width)
+           pango_layout_set_width (label->layout, width);
+       }
     }
 
   if (label->select_info && label->select_info->window)
@@ -2285,12 +2296,14 @@ get_layout_location (GtkLabel  *label,
   if (label->ellipsize || priv->width_chars > 0)
     {
       int width;
+      PangoRectangle logical;
 
-      width = pango_layout_get_width (label->layout);
-      if (width == -1)
-       pango_layout_get_pixel_size (label->layout, &req_width, NULL);
-      else
-       req_width = PANGO_PIXELS (width);
+      pango_layout_get_pixel_extents (label->layout, NULL, &logical);
+
+      req_width = logical.width;
+      if (width != -1)
+       req_width = MIN(PANGO_PIXELS (width), req_width);
+      req_width += 2 * misc->xpad;
     }
   else
     req_width = widget->requisition.width;